package org.starlight.user.serivce.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.starlight.delete.DeleteRecordHelper;
import org.starlight.delete.enums.TableEnum;
import org.starlight.user.entity.Menu;
import org.starlight.user.repository.MenuRepository;
import org.starlight.user.serivce.MenuService;

/**
 * @author huangyong
 * @data 2025/2/28
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class MenuServiceImpl implements MenuService {
    private final MenuRepository menuRepository;

    @Override
    public void save(Menu menu) {
        menuRepository.save(menu);
    }

    @Override
    public void del(Integer id) {
        DeleteRecordHelper.saveDeleteRecord(TableEnum.menu, menuRepository.findById(id).orElse(null));
        menuRepository.deleteById(id);

    }
}
